<template>
  <div>
    <el-timeline :reverse="reverse">
      <el-timeline-item
        v-for="(activity, index) in dataTime"
        :key="index"
        :color="activity.color"
        :timestamp="activity.time"
      >
        {{ activity.content }}
      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script>
export default {
  props: {
    row: {
      type: Object,
      reqired: true,
      default: () => ({})
    }
  },
  data() {
    return {
      reverse: false,
      dataTime: []
    };
  },
  mounted() {
    this.formatDataTime();
  },
  methods: {
    subDataTime(str) {
      return str.substring(0, str.length - 3);
    },
    formatDataTime() {
      if (this.row.paymentTime) {
        this.dataTime.push({
          // 支付时间
          content: 'Payment At',
          time: this.subDataTime(this.row.paymentTime)
        });
      }
      if (this.row.createTime) {
        this.dataTime.push({
          // 创建时间
          content: 'Create At',
          time: this.subDataTime(this.row.createTime)
        });
      }
      if (this.row.submitTime) {
        this.dataTime.push({
          // 提交时间
          content: 'Submit At',
          time: this.subDataTime(this.row.submitTime)
        });
      }
      if (this.row.printTime) {
        this.dataTime.push({
          // 打印时间
          content: 'Print At',
          time: this.subDataTime(this.row.printTime)
        });
      }
      if (this.row.shippedTime) {
        this.dataTime.push({
          // 发货时间
          content: 'Shipped At',
          time: this.subDataTime(this.row.shippedTime)
        });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
ul {
  padding: 0;
}
.el-timeline-item {
  padding-bottom: 6px;
}
::v-deep .el-timeline-item__wrapper {
  padding-left: 15px;
  font-size: 12px;
  .el-timeline-item__content {
    display: inline-block;
  }
  .el-timeline-item__timestamp {
    display: inline;
  }
}
</style>
